<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" placeholder="请输入一个年份" class="ipt1" />
    <button>提交</button> <input type="text" class="ipt2" />
  </body>
</html>
<script>
  var oIpt1 = document.querySelector(".ipt1");
  var oIpt2 = document.querySelector(".ipt2");
  var oBtn = document.querySelector("button");
  oBtn.onclick = function () {
    if (oIpt1.value.trim() == "") return alert("请输入内容");
    if (isNaN(oIpt1.value)) return alert("请输入数字");
    if (
      (oIpt1.value % 4 === 0 && oIpt1.value % 100 !== 0) ||
      oIpt1.value / 400 === 0
    ) {
      oIpt2.value = "是闰年";
    } else {
      oIpt2.value = "不是闰年";
    }
  };
</script>
